# class Dog:
#     def __init__(self,name,age):
#         self.name = name
#         self.age = age
#     def sit(self):
#         """小狗坐下"""
#         print(f"{self.name} is now siting")
#     def rap(self):
#         """叫"""
#         print(f"{self.name} is wa wa wa")
# my_dog = Dog("大黄",8)
#
# your_dog = Dog("小黄",3)
# print(f'my dog is {my_dog.name}')
# my_dog.sit()
# your_dog.sit()


'''class Restaurant:
    def __init__(self,name,type):
        self.name = name
        self.type = type
    def open_restaurant(self):
        print(f'The  {self.name} is working at {self.type}.')
aaa=Restaurant('kfc', 'wanda')
aaa.open_restaurant()'''




class Car:
    def __init__(self,make ,model,year):
        self.make = make
        self.model = model
        self.year = year
        self.odometer_reading = 0

    def describe_car(self):
        long_name = f'{self.year} {self.make} {self.model}'
        return long_name.title()

    def open_restaurant(self):
        print(f'The{self.model} is working at {self.odometer_reading}')


     # 通过方法修改属性的值
    def update_odometer(self,mileage):
        if mileage >= self.odometer_reading:
            self.odometer_reading = mileage
        else:
            print('You cannot')
        # self.odometer_reading = mileage
    def increment_odometer(self,extra):
        self.odometer_reading += extra

my_car = Car('audi', 'toyota', '2020')
print(my_car.describe_car())
my_car.open_restaurant()
# 直接修改属性的值
my_car.odometer_reading = 23
my_car.open_restaurant()
my_car.update_odometer(77)

my_used_car = Car('audi', 'toyota', '1231')
my_used_car.increment_odometer(100)
my_car.open_restaurant()


class ElectricCar(Car):
    def __init__(self,make,model,year):
        super().__init__(make,model,year)
my_electric_car = ElectricCar('小米汽车','sja',1)
print(my_electric_car.describe_car())
